/**
 * Created by ybjaa on 2017/5/27.
 */


/**
 * 文件下载的model
 */
export class DownloadFile{

    public ID:number;
    public size:number=0;
    public suffix:string="";

    public get Size(){
        return this.getSizeStr(this.size);
    }


    protected getSizeStr(size:number):string {
        if (size < 0) return size + "";
        if (size < 1024) return size + "B";
        let m;
        m = size / 1024.0;
        if (m < 1024) return m.toFixed(2) + "KB";
        m = m / 1024.0;
        return m.toFixed(2) + "MB";

    }


    public CopyFrom(value:DownloadFile){
        this.ID=value.ID;
        this.size=value.size;
        this.suffix=value.suffix;
    }





}